export let MyTrigger = {
  tagName: 'u-trigger-radio',
  template: `<div class="u-trigger-radio" @click="handleClick">
<!--    {{state}}-->
      <div :hidden="state !== 'yes'"><slot name="yes"></slot></div>
      <div :hidden="state === 'yes'"><slot name="no"></slot></div>
    <slot></slot>
  </div>`,
  props: {
    checked: Boolean
  },
  watch: {
    checked(newVal) {
      this.state = newVal ? 'yes' : 'no'
    }
  },
  data() {
    return {
      state: this.checked ? 'yes' : 'no',
    }
  },
  methods: {
    handleClick() {
      if (this.state === 'no') {
        this.$emit('oncheck')
      } else {
        this.$emit('onnocheck')
      }
    }
  }
}
